#ifndef QCLOCKWIDGET_H
#define QCLOCKWIDGET_H

#include "../../libs/shared/host/qwidgethost.h"
#include "../../libs/qwt/qwt_analog_clock.h"
#include "../../libs/shared/property/qabstractproperty.h"
#include "../../libs/shared/qcommonstruct.h"

#include "qwtdialhost.h"

#include <QWidget>

class QIntProperty;
class QEnumProperty;
class QBoolProperty;
class QColorProperty;


#include <QVariant>

class QClockNeedleProperty: public QAbstractProperty
{
    Q_OBJECT
public:
    Q_INVOKABLE QClockNeedleProperty(QAbstractProperty* parent=0);

    void            set_value(const QVariant &value);

    QString         get_value_text();
    QIcon           get_value_icon();
    static QString get_property_name();

    bool            cmp(const QVariant &value);
protected:
    void            child_value_changed(const QVariant &old, const QVariant &now);
    void            make_value();
    void            write_value();
protected:
    QEnumProperty   *m_style;
    QIntProperty    *m_width;
    QColorProperty  *m_color;
    QColorProperty  *m_knob_color;
    QBoolProperty   *m_knob_visible;
};

class QClockWidget: public QwtAnalogClock
{
    Q_OBJECT
    Q_PROPERTY( tagNeedleInfo hour_needle READ hourNeedle WRITE setHourNeedle )
    Q_PROPERTY( tagNeedleInfo min_needle READ minNeedle WRITE setMinNeedle )
    Q_PROPERTY( tagNeedleInfo second_needle READ secondNeedle WRITE setSecondNeedle )
public:
    QClockWidget(QWidget* parent=0);

    tagNeedleInfo   hourNeedle();
    void            setHourNeedle(const tagNeedleInfo &info);

    tagNeedleInfo   minNeedle();
    void            setMinNeedle(const tagNeedleInfo &info);

    tagNeedleInfo   secondNeedle();
    void            setSecondNeedle(const tagNeedleInfo &info);
protected:
    tagNeedleInfo   m_hour_needle;
    tagNeedleInfo   m_min_needle;
    tagNeedleInfo   m_second_needle;
};

class QClockWidgetHost : public QwtDialHost
{
    Q_OBJECT
public:
    Q_INVOKABLE QClockWidgetHost(QAbstractHost *parent = 0);

    static QString get_show_name();
    static QString get_show_icon();
    static QString get_show_group();
protected:
    void init_property();
protected:
    void    create_object();
};

#endif // QCLOCKWIDGET_H
